import {createStore} from 'vuex';

export default createStore({
  state () {
    return {
      multiPage: true,
      reloadFlag: true,
      cachedViews: [],
      routePathComponentMap: {},
      menuCollapse: false,
      globalLayout: 'simple', //normal, simple
      theme: 'dark' //normal, simple
    }
  },
  getters: {
    multiPage: state => state.multiPage,
    reloadFlag: state => state.reloadFlag,
    cachedViews: state => state.cachedViews,
  },
  mutations: {
    setMultiPage(state, multiPage) {
      state.multiPage = multiPage;
    },
    setReloadFlag(state, reloadFlag) {
      state.reloadFlag = reloadFlag
    },
    addCacheView(state, path) {
      state.cachedViews.push(path);
    },
    removeCacheView(state, index) {
      state.cachedViews.splice(index, 1);
    },
  },
})
